package com.luanye.enjoy.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.luanye.enjoy.dto.ConditionDTO;
import com.luanye.enjoy.entity.Topic;
import com.luanye.enjoy.enums.ResultCode;
import com.luanye.enjoy.mapper.TopicMapper;
import com.luanye.enjoy.service.TopicService;
import com.luanye.enjoy.vo.RespBean;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;


@Service("topicService")
@AllArgsConstructor
public class TopicServiceImpl extends ServiceImpl<TopicMapper, Topic> implements TopicService {

    private final TopicMapper topicMapper;

    @Override
    public RespBean customTopic(ConditionDTO dto) {
        Topic topic = new Topic();
        topic.setTopic(dto.getTopic());

        boolean isSuccess = save(topic);
        if (!isSuccess){
            return RespBean.error(ResultCode.FAILED);
        }
        return RespBean.success(topic);
    }

    @Override
    public RespBean getHotList() {
        return RespBean.success(topicMapper.getHotTopicList());
    }


}
